import axios from 'axios';
import * as contains from './typeAction';

const changeLogin = (value) =>({
	type: contains.CHANGE_LOGIN,
	value: true
})

export const logout = (value) => ({
	type: contains.LOGIN_OUT,
	value: false
})

export const login = (accout, password) => {
	return (dispatch) => {
		axios.get('/api/login.json?accout=' + accout + '&password=' + password).then((res) => {
			const result = res.data.data;
			if(result){
				dispatch(changeLogin())
			}else{
				alert('登录失败')
			}
		})
	}
}